package com.gomokult.servlet.comment;

import com.gomokult.exception.InvalidIDException;
import com.gomokult.service.impl.CommentServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/servlet/GetCommentPagesCountServlet")
public class GetCommentPagesCountServlet extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        int gameID = Integer.parseInt(request.getParameter("gameID"));
        int pagesCount = 0;
        try {
            pagesCount = CommentServiceImpl.getSingleton().getCommentPagesCount(gameID);
            out.print(pagesCount);
        } catch (InvalidIDException e) {
            out.print("#InvalidIDException");
        }
    }
}
